#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
	FILE *f;
	if(argc<4) {printf("arg1: value arg2: offset arg3: length\n"); exit(0); }
	int value, offset, length;
	value=atoi(argv[1]);
	offset=atoi(argv[2]);
	length=atoi(argv[3]);
	f=fopen("/dev/fb0","w");
	if(f==0){perror("/dev/fb0"); exit(1);}
	int i;
	if(fseek(f, offset*2, 0)==-1){perror("fseek"); exit(1);}
	for(i=0;i<length;i++){
		if(fprintf(f,"%c",(char)(value&0xFF))==0) {perror("fprintf"); exit(1);}
		if(fprintf(f,"%c",(char)(value>>8))==0) {perror("fprintf"); exit(1);}
	}
	fclose(f);
	return 0;
}
